
<script type="text/javascript" src="tpl/_res/pc/js/jquery.js?v={$setting[Version]}"></script>
<script type="text/javascript" src="tpl/_res/pc/js/jquery.extend.js?v={$setting[Version]}"></script>

<link href="static/css/parser.css?v={$setting[Version]}" rel="stylesheet" type="text/css"/>

<script>
    function block_add(){
        $('body').append('<div class="-ilinei-block" tag="blank"><p class="-ilinei-icon"></p></div>');

        block_bind_event();
    }

    function block_bind_event(){
        $('.-ilinei-block').unbind('hover').hover(function(){
            $(this).addClass('-ilinei-block-hover');
        }, function(){
            $(this).removeClass('-ilinei-block-hover');
        });

        $('.-ilinei-block .-ilinei-icon').unbind('click').click(function(){
            var tag = $(this).parent();
            var tag_name = $(tag).attr('tag');

            var message = '';
            message += '<p class="-ilinei-operate">';
            message += '<button type="button" class="btn-add-prev">上部添加标签</button>';
            message += ' | ';
            message += '<button type="button" class="btn-add-next">下部添加标签</button>';
            message += ' | ';
            message += '<button type="button" class="btn-add-interval">内部添加标签</button>';
            message += ' | ';
            message += '<button type="button" class="btn-delete">删除</button>';
            message += '</p>';

            if(tag_name == 'block'){
                var file = $(tag).attr('file');
                if(!file){
                    message += 'model:' + $(tag).attr('model') + '<br/>';
                    message += 'method:' + $(tag).attr('method') + '<br/>';
                    message += 'identity:' + $(tag).attr('identity') + '<br/>';
                    message += 'param:' + $(tag).attr('param') + '<br/>';
                    message += 'var:' + $(tag).attr('var') + '<br/>';
                    message += 'pager:' + $(tag).attr('pager') + '<br/>';
                }else{
                    message += 'file:' + $(tag).attr('file') + '<br/>';
                }
            }

            message += '{lang admin.ilinei.frame_parser.view.block.tag.tips}';

            $.dialog({css:'-ilinei-dialog', height:120, title:tag_name + '{lang admin.ilinei.frame_parser.view.block.tag}', message:message, callback:function(){
                $('#_dialog .-ilinei-operate .btn-add-prev').click(function(){
                    $('<div class="-ilinei-block" tag="blank"><p class="-ilinei-icon"></p></div>').insertBefore(tag);
                    $.dialog({close:true});

                    block_bind_event();
                });

                $('#_dialog .-ilinei-operate .btn-add-next').click(function(){
                    $('<div class="-ilinei-block" tag="blank"><p class="-ilinei-icon"></p></div>').insertAfter(tag);
                    $.dialog({close:true});

                    block_bind_event();
                });

                $('#_dialog .-ilinei-operate .btn-add-interval').click(function(){
                    $(tag).append('<div class="-ilinei-block" tag="blank"><p class="-ilinei-icon"></p></div>');
                    $.dialog({close:true});

                    block_bind_event();
                });

                $('#_dialog .-ilinei-operate .btn-delete').click(function(){
                    $.dialog({css:'-ilinei-dialog', message:'您确认删除此标签吗？', button:{cancel:'取消', submit:'确认删除'}, submit:function(){
                        $(tag).remove();
                    }});
                });
            }});
        });
    }

    $(function(){
        block_bind_event();
    });
</script>